#include "utilities/DataAllocator.h"
#include <assert.h>

DataAllocator::DataAllocator()
{
	//m_Lock.lock();
	for (int i = 0; i < 3; ++ i)
	{
		m_Heaps[i] = HeapCreate(0,0,0);

		assert(m_Heaps[i] != NULL);
	}
}

DataAllocator::~DataAllocator()
{
	for (int i = 0; i < 3; ++ i)
	{
		HeapDestroy(m_Heaps[i]);
	}
}

void* DataAllocator::malloc(size_t n)
{
	return n <= 150 ? HeapAlloc(m_Heaps[0],0,n) : HeapAlloc(m_Heaps[1],0,n);
// 	int i;
// 	if (n <= 150)
// 		i = 0;
// 	else if (n <= 1200)
// 		i = 1;
// 	else
// 		i = 2;
// 
// 	return HeapAlloc(m_Heaps[i],0,n);
}

void DataAllocator::free(void* ptr,size_t n)
{
	n <=150 ? HeapFree(m_Heaps[0],0,ptr) : HeapFree(m_Heaps[1],0,ptr);
// 	int i;
// 	
// 	if (n <= 150)
// 		i = 0;
// 	else if (n <= 1200)
// 		i = 1;
// 	else
// 		i = 2;
// 	
// 	HeapFree(m_Heaps[i],0,ptr);
}